<!doctype html>
<html>
{include file='index/header' title='发布留言-音乐之家'}
{include file='index/read_header'}
{include file='index/effect_header'}

<style type="text/css">
  form {
    display: block;
    margin-top: 0em;
    vertical-align:middle
  }
  .form-horizontal .control-label {
    padding-top: 7px;
    margin-bottom: 0;
    text-align: left;
    margin-top: -10px;
  }

</style>

<!--<script type="text/javascript">-->
<!--  $(document).ready(function(){-->
<!--    $("#jMenu").jMenu();-->
<!--  })-->
<!--</script>-->

<!--<body style="background-size: 100% 100%;-->
<!--            position: absolute;width:100%;height: 100%">-->
<body style="background: azure;">

<div class="container" style="margin-top:-4px;">

<!--    <div class="box" style="display: flex;justify-content:center;flex-direction: column;align-items: center;">-->
<!--        <ul class="minbox">-->
<!--            <li></li>-->
<!--            <li></li>-->
<!--            <li></li>-->
<!--            <li></li>-->
<!--            <li></li>-->
<!--            <li></li>-->
<!--        </ul>-->
<!--        <ol class="maxbox">-->
<!--            <li></li>-->
<!--            <li></li>-->
<!--            <li></li>-->
<!--            <li></li>-->
<!--            <li></li>-->
<!--            <li></li>-->
<!--        </ol>-->
<!--    </div>-->
<div id="controller">
  <!--修改密码 弹窗 -->
  {include file='index/change_pwd'}
  {include file='index/personal'}
  <div class="container" style="margin-top:10px;">
    {include file='index/contact'}
  </div>
</div>
<form class="form-horizontal"  action="__ROOT__/addarticle/{$name ?? 'unknown'}" method="post">

  <div class="form-group"  style="display: flex;justify-content:center;flex-direction: column;align-items: center;">
    <label class="col-sm-2 control-label" style="font-size: 18px;width: 80%">选择模块</label>
    <div class="col-sm-10">
      <select type="text" class="form-control" name="module" style="font-size: 18px;width: 80%">
        <option value="">请选择模块</option>
        <option value="0">其他</option>
        <option value="1">吉他模块</option>
        <option value="2">钢琴模块</option>
      </select>

    </div>
  </div>

  {if condition="isset($level)"}
  <div class="form-group"  style="display: flex;justify-content:center;flex-direction: column;align-items: center;">
    <label class="col-sm-2 control-label" style="font-size: 18px;width: 80%">是否私密留言</label>
    <div class="col-sm-10">
      <select type="text" class="form-control" name="private" style="font-size: 18px;width: 80%">
        <option value="">请选择</option>
        <option value="0">否</option>
        <option value="1">是</option>
      </select>

    </div>
  </div>
  {/if}

  <div class="form-group"  style="display: flex;justify-content:center;flex-direction: column;align-items: center;">
    <label class="col-sm-2 control-label" style="font-size: 18px;width: 80%">标题</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" name="title" placeholder="请输入标题" v-model="title">
    </div>
  </div>

  <div class="form-group" style="display: flex;justify-content:center;flex-direction: column;align-items: center;">
    <label  class="col-sm-2 control-label" style="font-size: 18px;width: 80%;">内容</label>
    <div class="col-sm-10">
      {include file='index/editor'}
    </div>
  </div>

  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-primary saveContent" style="margin-left: 34.666667%">发布留言</button>
    </div>
  </div>
</form>

</div>

</body>

<script >

  var controller = new Vue({
    el : '#controller',
    data : {
      username: localStorage.mUser,
      title:'',
      content:'',
      changeP:false,
      abnormal_card:'',
      singular:{
        oldPWD:'',
        newPWD:'',
        newPWDr:'',
      },
      personal_button:false,
      personal_list:{},
      auth_level:true,
    },
    created: function() {
		this.online();
		this.getData();
    },
    // mounted() {
    //   // 关闭浏览器窗口的时候清空浏览器缓存在localStorage的数据
    //   window.onbeforeunload = function (e) {
    //     var storage = window.localStorage;
    //     storage.clear()
    //   }
    // },
    methods : {
	    online:function() {
                var _self = this;
                libs.ajax('index/index/checkOnline', {

                },function (result) {
                    if(result.status==1)
                    {
                        alert('您已离线，请登录！');
                        localStorage.clear();
                        window.location.href = '/login'
                    }
                })
            },
        getData:function() {
          var _self = this;
          libs.ajax('index/index/checkUserInfo', {

          },function (result) {
            if(result.status==0)
            {
              if(result.auth_level == 0)
              {
                _self.auth_level = false
              }
            }
          })
        },
        dologout: function() {
          if (!confirm('您确定退出吗?')) return;
          libs.ajax('index/login/DoLogout', {
          }, function(result) {
            alert(result.msg)
            if(result.status == 0)
            {
              localStorage.clear();
              location.reload();
                window.location.href = '/'
            }

          })
        },
        add_article:function () {
          var _self= this;
           libs.ajax('index/index/add_article', {
               title:_self.username,
               content:_self.content,
           }, function(result) {

               if(result.status == 0)
               {
                   alert(result.msg)
                   window.location.href = '/'
               }

           })

       },
      changePwd(){
        this.changeP=true;
        this.singular={}
      },
      send: function() {
        var _self = this;

        if(!_self.singular.oldPWD || !_self.singular.newPWD || !_self.singular.newPWDr){
          alert('表单不能为空')
          return;
        }

        if (_self.singular.newPWD.length < 6 || _self.singular.newPWD.length > 20) {
          alert("密码长度必须为6-20位，请重新输入！");
          return;
        }

        if (_self.singular.newPWD != _self.singular.newPWDr) {
          alert("新设置密码两次不一致，请重新输入！");
          return;
        }
        libs.ajax('index/regist/ChangePassword', {
          old_pwd : _self.singular.oldPWD,
          new_pwd : _self.singular.newPWD,
          new_pwd_a : _self.singular.newPWDr
        }, function(result) {
          alert(result.msg)
          if(result.status == 0){
            localStorage.clear()
            top.location.href = '/'
          }
        })
      },
      /*个人信息接口*/
      personal(){
        var _self = this;
        this.personal_button=true;
        libs.ajax('index/index/personal_info', {
        }, function(result) {
          _self.personal_list = result.data;
          console.log(_self.personal_list);
        })
      },
    }
  })
</script>
</html>
